package com.itrident.handler;

import com.intellij.openapi.project.Project;
import com.itrident.store.EnumsManagerPersistentState;
import com.itrident.store.EnumsWrapper;
import com.itrident.store.PropManagerPersistentState;
import com.itrident.store.PropManger;

import java.util.List;

/**
 * @author cxx
 * @create 2021-04-20 15:06
 **/
public class RecodeEnumsHandler {


    private static final String CODE = "itr.enums.name";
    private static final String DESC = "itr.enums.desc";

    public static String getCode(Project project){
        PropManger propManger =getPropManger(project);
        return propManger.get (CODE);
    }

    public static void setCode(Project project,String val){
        PropManger propManger =getPropManger(project);
        propManger.add (CODE,val);
    }

    public static String getDesc(Project project){
        PropManger propManger =getPropManger(project);
        return propManger.get (DESC);
    }

    public static void setDesc(Project project,String val){
        PropManger propManger =getPropManger(project);
        propManger.add (DESC,val);
    }
    private static PropManger getPropManger(Project project){
        PropManagerPersistentState propManagerPersistentState = PropManagerPersistentState.getInstance (project);
        PropManger propManger = propManagerPersistentState.getState ();
        return propManger;
    }

    public static void reloadRecodeEnums(Project project) {
        EnumsManagerPersistentState persistentState = EnumsManagerPersistentState.getInstance (project);
        persistentState.reload (project);
    }

    public static void delAllRecodeEnums(Project project) {
        EnumsManagerPersistentState persistentState = EnumsManagerPersistentState.getInstance (project);
        persistentState.delAll ();
    }

    public static List<EnumsWrapper> getAllRecodeEnums(Project project) {
        EnumsManagerPersistentState persistentState = EnumsManagerPersistentState.getInstance (project);
        return persistentState.getEnumsWrapper ();
    }
}
